package com.zeng.nicecore.util;

import com.zeng.nicecore.constant.IgnoreConstant;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;


public class IgnoreStringUtil {
    static List<String> ignore = Arrays.asList(new String[]{
            IgnoreConstant.code.getValue(),
            IgnoreConstant.updateDate.getValue(),
            IgnoreConstant.insertDate.getValue(),
            IgnoreConstant.valid.getValue(),
            IgnoreConstant.id.getValue(),
            IgnoreConstant.version.getValue()});

    public static String[] ignoreExclude(String... exclude) {
        List<String> copy = new ArrayList<>(ignore.size());
        for (String s : ignore) {
            copy.add(s);
        }

        for (String s : exclude) {
            boolean remove = copy.remove(s);
            if (!remove) {
                throw new RuntimeException("ignore properties not exist");
            }
        }
        String[] targets = new String[copy.size()];
        return copy.toArray(targets);

    }

    public static String[] ignoreInclude(String... include) {
        List<String> copy = new ArrayList<>(ignore.size());
        for (String s : ignore) {
            copy.add(s);
        }
        for (String s : include) {
            copy.add(s);
        }
        String[] targets = new String[copy.size()];
        return copy.toArray(targets);
    }

}
